var app = getApp();
Page(Object.assign({}, {
    data:{
        page : {
            isend : false,
            doing : false,
            doo : 'admin',
            pdata : {
                op : 'cardgetlog',
                page : 1,
                type : 0,
                cardid : 0,
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
        card : {},
        actindex : 0,
        isredbag : false,
        isaddm : false,
        issetfee : false,
        startfee : '',
        endfee : '',
        startfeep : '',
        endfeep : '',
        addfee : '',
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;
        var cid = options.cid ? options.cid : 0;

        self.data.options = options;
        self.setData({
            datalist : [],
            'page.isend' : false,
            'page.pdata.page' : 1,
            'page.pdata.cardid' : cid,
        })

        app.com.auth(function(user){
            app.com.getPage(self,self.data.page,0,function(res){
                var data = res.data.data;
                self.setData({
                   datalist : data.list,
                   params : data.params,
                   inited : true,
                });
            },false,function(res){
                app.com.alert( res.data.message,function(){
                    app.globalData.adminurl = app.com.getUrlArgs();
                    if( res.data.errno == 2 ){
                        wx.navigateTo({
                            url : res.data.data.url
                        });
                    }
                });
            });
        },self);
        
        wx.setNavigationBarTitle({
          title: '领取优惠券记录',
        });
        
    },
    onShareAppMessage : function(){
        var self = this;
        return {
            title: '领取优惠券记录',
            path: '',
        }
    },
    onPullDownRefresh: function () {
        this.onLoad(this.data.options);
        // 关闭下拉刷新
        wx.stopPullDownRefresh();
    },
    onReachBottom : function(){
        var self = this;
        app.com.getPage(self,self.data.page,0,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    }
}))